package com.dys.test11;

/**
 * @className: com.dys.test11.Student
 * @description: com.dys.test11
 * @author: pine cone
 * @version: v1.0.0
 * @createTime: 2024/07/23 下午10:22
 */
public class Student {
    // 封装属性
    private String name;
    private int age;
    private String gender;

    public Student() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        if ("男".equals(gender) || "女".equals(gender)) {
            this.gender = gender;
        } else {
            // throw new MyRuntimeException("对不起,性别有误!");
            try {
                throw new MyException();
            } catch (MyException e) {
                e.printStackTrace();
            }
        }
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", gender='" + gender + '\'' +
                '}';
    }
}
